/**
 * 字符串字面量类型
 */
type Easing = "ease-in" | "ease-out" | "ease-in-out";
class UIElement {
  animate(dx:number,dy:number,easing:Easing){
    if(easing === "ease-in") {
      console.log("easein");
    }else if(easing === "ease-out") {
      console.log("ease-out");
    }else if(easing === "ease-in-out") {
      console.log("ease-in-out");
    }else{
      console.log("other");
    }
  }
}
let button = new UIElement();
button.animate(0,0,"ease-in");
// button.animate(0,0,"uneasy"); //类型“"uneasy"”的参数不能赋给类型“Easing”的参数

// 字符串字面可以通过相同的方式用来分别重载：
// function createElement(tagName: "img"): HTMLImageElement{
//   let a:any
//   return  a as HTMLImageElement
// }
// function createElement(tagName: "input"): HTMLInputElement {
//   let a:any
//   return  a as HTMLInputElement
// }
// function createElement(tagName: string): Element {
//   let a:unknown;
//   return a as Element
// }

/**
 * 数字字面量类型
 */
function rollDice():1 | 2 | 3 | 4 | 5 | 6 {
  return (Math.floor(Math.random()*6)+1) as 1 | 2 | 3 | 4 | 5 | 6 ;
}
const result4 = rollDice();
interface MapConfig{
  lng:number;
  lat:number;
  tilesSize: 8 | 16 | 32 ;
}
function setupMap(arg0: { lng: number; lat: number; tilesSize: number; }) {
  throw new Error("Function not implemented.");
}
setupMap({lng:-732.3,lat:32.66666,tilesSize:16})

/**
 * 布尔字面量类型
 */
interface ValidationSuccess {
  isValue:true;
  reason:null;
}
interface ValidationFailure {
  isValue:false;
  reason:string;
}

type ValidationResult = ValidationSuccess | ValidationFailure